#include <iostream>
using namespace std;
int kai(int);
int main ()
{
	int n;
	cin>>n;
	cout<<kai(n);
	return 0;
}
int kai(int m)
{
	return m==1?1:kai(m-1)*3-1;
}
